package com.zhangshuo.patternDesign.resrponsibility;

/**
 * Created by shuo.zhang on 2017-11-03.
 */
public class McManager {

    private IMcSubbranch head;
    private IMcSubbranch next;

    public  McManager addIMcSubbranch(IMcSubbranch iMcSubbranch){
        if (this.head == null){
            head = iMcSubbranch;
            return this;
        }

        iMcSubbranch.setSuccessor(head);
        head = iMcSubbranch;
        return this;
    }



    public boolean handleOrder(Order order){
        if (head ==null)
            return false;

        return head.handleOrder(order);
    }


    /**
     * 获取单例
     * @return
     */
    public static McManager getMcManager(){
        return McManagerInstance.instance;
    }


    private McManager(){}

    private static class McManagerInstance{
        private static McManager instance = new McManager();
    }



}
